﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Dapper;
using System.Collections;
using Oracle.ManagedDataAccess.Client;
using VOL.Core.Configuration;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using System.Diagnostics;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
/// <summary>
/// 连接oracle数据库，by huangxs 2022年2月27日 11:27:02
/// </summary>
namespace VOL.Core.DBManager
{
    public static class Other_Oracle_Helper
    {

        public static JObject get_appsettings()
        {
            JObject jObject = new JObject();
            string path = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;//获取应用程序运行的目录
            System.IO.StreamReader file = System.IO.File.OpenText(path + "/appsettings.json");
            using (JsonTextReader reader = new JsonTextReader(file))
            {
                jObject = JObject.Load(reader);
            }
            return jObject;
        }
        public static List<T> query<T>(string sqlstr, string ConnStr)
        {

            JObject jj = get_appsettings();
            string conntionstring = jj.SelectToken("Connection").SelectToken("other_db").SelectToken(ConnStr).ToString();//读取json文件节点数据,数据库连接配置信息
            
            List < T > rtnlist = null;
            using (OracleConnection conn = new OracleConnection(conntionstring))
              {
                  conn.Open();
                  rtnlist = (List<T>)conn.Query<T>(sqlstr);
                  conn.Close();
              }
            return rtnlist;
        }

        
        
    }
    }
